package frameLog

import (
	"queue/library/Log"
	"time"
)

var logger *Log.Logger

//初始化logger
func NewLogger(filePath, nameFormat, suffix string) {
	if logger != nil {
		return
	}
	//filePath := "./runtime/"
	//nameFormat:="2006-01-02 15:04:05.9999"
	//suffix:=".log"
	date := time.Now().Format(nameFormat)
	fileName := date + suffix
	writer := Log.NewWriter(filePath, fileName)
	logger = Log.NewLogger(writer, 2, 0, filePath, nameFormat, suffix)
}

func Info(vars ...interface{}) {
	logger.Write("INFO", vars...)
}

func Infof(format string, vars ...interface{}) {
	logger.Writef("INFO", format, vars...)
}
func Notice(vars ...interface{}) {
	logger.Write("NOTICE", vars...)
}
func Noticef(format string, vars ...interface{}) {
	logger.Writef("NOTICE", format, vars...)
}
func Warring(vars ...interface{}) {
	logger.Write("WARRING", vars...)
}
func Warringf(format string, vars ...interface{}) {
	logger.Writef("WARRING", format, vars...)
}
func Debug(vars ...interface{}) {
	logger.Write("DEBUG", vars...)
}
func Debugf(format string, vars ...interface{}) {
	logger.Writef("DEBUG", format, vars...)
}
func Error(vars ...interface{}) {
	logger.Write("ERROR", vars...)
}
func Errorf(format string, vars ...interface{}) {
	logger.Writef("ERROR", format, vars...)
}
func Panic(vars string) {
	logger.Write("PANIC", vars)
	panic(vars)
}

//在 main 函数开始是将其挂起，程序结束时关闭
func Close() {
	logger.Close()
}
